Skip to main content

Creating the REST integration interface

5 Tasks

1 hr 30 mins

Visible to: All users
Advanced Pega Platform '23 English

Scenario

The executive manager approves or rejects the truck after the vendor registers the truck. If approved, the city manager is assigned to rank the companies that will provide truck services for that city. 

To retrieve a truck's rating, provide its VIN to an external system. The average rating of all trucks belonging to that company becomes the initial rating of the company. The Global Truck Rating System (GTRS), a centralized truck rating system, will provide the rating for a given VIN belonging to a state. The company's initial rating is overridden after every delivery is completed. The city manager will rank every truck after delivery, which impacts the truck company's rating. The average of all truck ratings will be the rating of the truck company. An update of the truck rating will be sent to GTRS. 

The following table provides the credentials you need to verify the solution:

Role User name Password
Admin admin@deliveryservice rules
Admin admin@gtrs rules

You must initiate your own Pega instance to complete this Challenge.

Initialization may take up to 5 minutes so please be patient.

Detailed Tasks

1 Identify design options

There are two design options to obtain the rating from GTRS:

  1. Use the out-of-the-box data API and data pages to obtain the truck rating, as shown in the following figure:
    Data-API
  2. Create new Service-REST in the GTRS and invoke the custom service using a connector 

Similarly, there are two options to update the truck rating after delivery:

  1. Use the out-of-the-box Constellation APIs to update an existing record. The out-of-the-box API uses savable data pages to update or create a new record, as shown in the following figure:​​​
Constellation-API
  1.  Create a new service in the GTRS application to update the truck rating.

2 Evaluate design options

Review the pros and cons of each design option.

​​​​​​Get the truck rating

The following table describes the design options to retrieve the truck rating:

Design Pros Cons
Use out-of-the-box Pega Platform™ REST API {data GET methods}
  • Leverages out-of-the-box Pega Platform feature with minimal development effort.
  • Handle the business logic in the data page, Pega platform will take care of handling the request, response.
  • No support for value list, value group, page group properties.
Create a custom REST service in the GTRS application
  • Possible to have custom request and responses.
  • More development effort to build REST APIs.
  • Maintenance effort is more, to make the changes in both the applications.

 Update the truck rating

The following table describes the design options to update the truck rating:

Design Pros Cons
Use out-of-the-box Pega Platform REST API {data PUT methods}
  • Uses out-of-the-box Pega Platform feature with minimal development effort.
  • The design does not fully support the creation and updated of records of embedded pages (Page and Page lists) are not fully supported. They are tied with the Constellation UI.
Create a custom REST service in the GTRS application
  • Possible to have custom request and responses.
  • More development effort to build REST APIs.
  • More maintenance effort.

3 Recommend the best design option

Review the following best practices for each design option.

Get the truck rating

Use the Pega Platform out-of-the-box REST API call as it does not require a lot of development effort and does not need to customize the response.

Update the truck rating

To update the truck rating, use the custom REST service because the out-of-the-box Pega APIs do not support embedded page updates.

4 Identify required configuration tasks

To implement a solution, according to the recommended design, you accomplish the following tasks:

  1. Create a connector to fetch the truck rating. Configure the REST connector with a request and response.
  2. Create a REST service in the GTRS application to update the truck rating.
  3. Create a connector in the Delivery service application to update the truck rating. Configure the REST connector with a request and response.

5 Review solution details

Review the solution details for the best design options:

Apply the connector to get the initial truck rating

  1. Log in with admin@deliveryservice and switch to the MDC application to access the GTRS data type.
  2. In Dev Studio, create a new Data Page with a MDC-Data-GTRS class.
    You update the source for the Data Page in the App Studio.
  3. After creating the Data Page, switch to App Studio, and then click Data to view the data objects and integrations.
  4. Open the GTRS data object and click on the Data pages tab.
    The newly created Data Page and its source is displayed.
  5. Click More > Configure source.
    For savable Data Pages, an additional Configure save options option is displayed.
  6. Select the system and configure the source as REST.
  7. Enter the endpoint URL for the out-of-the-box data API and mention the Data Page that gives the truck rating (D_GTRSTruckRating)hosturl/data/data_page.
  8. Refer to the Pega API documentation for the syntax to pass the parameters.
  9. Configure the authentication information and click Initialize call.
    The application settings for the URL and the authentication are generated for the connector.

The following figure is a snapshot of the GTRS Connect-REST Rule:

ConnectREST_GTRS

The following figure is a snapshot of Application Settings for BaseURL: 

Application settings for the Base URL.

The following figure is a snapshot of the authentication profile: 

Application settings for the GTRS-Auth-Profile.

You can map the response by using the response Data Transform on the Data Page, as shown in the following figure:

Configurable data srouces.

For more Pega API use cases, see City services example mobile app.

Update the truck rating

  1. Log in with admin@gtrs to create a service to update the truck rating.
    You can use savable Data Pages to update the rating for a truck in the service activity.
  2. Log in with admin@deliveryservice and switch to the MDC application.
  3. Create a savable Data Page in Dev Studio to update the truck rating in the GTRS application.
    Savable Data Pages can be used to invoke the truck rating service.
  4. In App Studio, open the GTRS data object and click Configure save options.
  5. Configure a new source with REST and provide the service URL from the GTRS application.
  6. Set the required parameters and authentication.
  7. In the next step, provide the request and response, and then save the Data Page.
    You can verify the configurations in Dev Studio.

The following figure shows the The Update rating savable Data Page:

The Update rating savable Data Page.

The system generates the application settings for the service URL and authentication, as shown in the following figure of the first API:

The generated settings for the service URL and authentication.

For more information, see Configuring a save plan for a Data Page in App Studio.

Confirm your work

      



Available in the following mission:

If you are having problems with your training, please review the Pega Academy Support FAQs.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega Academy has detected you are using a browser which may prevent you from experiencing the site as intended. To improve your experience, please update your browser.

Close Deprecation Notice